package com.example.love_margin.Controller;


import com.example.love_margin.Entity.Organization;
import com.example.love_margin.Service.OrganizationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@Api(value = "机构认证",tags = "机构认证")
@RestController
@RequestMapping(value = "/Organization" ,name = "机构认证")
@CrossOrigin
public class OrganizationController {


    @Autowired
    OrganizationService organizationService;

    @ApiOperation(value = "发布机构信息",notes = "需要：")
    @PostMapping(value = "/addOrganization")
    public Object addOrganization(@RequestBody Organization organization){
        return organizationService.addOrganization(organization);
    }

    @ApiOperation(value = "删除机构信息",notes = "需要：")
    @PostMapping(value = "/deleteOrganization")
    public Object deleteOrganization(@RequestParam int organization_id){
        return organizationService.deleteOrganization(organization_id);
    }

    /*
批量删除
*/
    @ApiOperation(value = "删除多个机构信息", notes = "删除多个机构信息")
    @PostMapping(value = "/deleteOrganizationMany")
    public Object deleteOrganizationMany(@RequestBody Integer[] organization_ids) {
        System.out.println(Arrays.toString(organization_ids));
        return organizationService.deleteOrganizations(organization_ids);
    }



    @ApiOperation(value = "查询单个机构信息",notes = "需要：sale_id")
    @GetMapping(value = "/selectOne")
    public Object selectOne(@RequestParam int organizationte_id){
        return organizationService.selectOrganization(organizationte_id);
    }

    @ApiOperation(value = "查询机构信息列表",notes = "请求即可")
    @GetMapping(value = "/selectOrganizations")
    public Object selectOrganizations(Integer pageNum,Integer pageSize){
        return organizationService.selectOrganizations(pageNum,pageSize);
    }

    @ApiOperation(value = "修改机构信息",notes = "需要：science_title，science_picture，science_type")
    @PostMapping(value = "/updateOrganization")
    public Object updateOrganization(@RequestBody Organization organization){
        return organizationService.updateOrganization(organization);
    }




}
